package com.sky.mapper;

import com.sky.entity.SetmealDish;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealDishMapper {
    /**
     *  根据菜品id批量查询菜品是否关联套餐
     */
    Integer getCountIdsByDishIds(@Param("dishIds") List<Long> dishIds);

    /**
     *  根据菜品id查询关联的套餐id
     */
    List<Long> getSetmealIdsByDishIds(@Param("dishIds") List<Long> dishIds);

    /**
     *  根据菜品id批量添加套餐和菜品关联信息
     */
    void save(List<SetmealDish> setmealDishes);

    /**
     *  根据套餐id删除套餐和菜品关联信息
     * @param setmealIds
     */
    void delete(List<Long> setmealIds);

    /**
     *  根据套餐id获取套餐菜品关联表中的菜品信息
     */
    @Select("select * from setmeal_dish where setmeal_id = #{setmealId}")
    List<SetmealDish> getDishBySetmealIds(Long setmealId);

    /**
     *  根据套餐id获取套餐包含的菜品id
     */
    @Select("select dish_id from setmeal_dish where setmeal_id = #{setmealId}")
    List<Long> getDishIdsBySetmealId(Long setmealId);
}
